#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string.h>
#include <cstdio>
using namespace std;

typedef struct
{
    double score;
    int age;
    char name[100];
} student;

student students[100];

bool cmp(student a, student b)
{
    if (a.score != b.score)
    {
        return a.score > b.score;
    }
    else
    {
        if (a.age != b.age)
        {
            return a.age < b.age;
        }
        else
        {
            return a.name < b.name;
        }
    }
}

int main()
{
    int N;
    char name[100];
    int age;
    double score;
    while (~scanf("%d", &N))
    {
        for (int i = 0; i < N; i++)
        {
            // cin >> students[i].name >> students[i].age >> students[i].score;
            scanf("%s %d %lf", name, &age, &score);
            if (strlen(name) <= 10 && age <= 20 && age > 0 && score > 0.0 && score <= 100.0)
            {
                strcpy(students[i].name, name);
                students[i].age = age;
                students[i].score = score;
            }
            else
            {
                i--;
                N--;
            }
        }
        sort(students, students + N, cmp);
        for (int i = 0; i < N; i++)
        {
            printf("%s %d %.2lf\n", students[i].name, students[i].age, students[i].score);
            /*
                if (i < N - 1)
                {
                    cout << students[i].name << " " << students[i].age << " " << fixed << setprecision(2) << students[i].score << endl;
                }
                else
                {
                    cout << students[i].name << " " << students[i].age << " " << fixed << setprecision(2) << students[i].score;
                }
            */
            /*
                if (i < N - 1)
                {
                    printf("%s %d %.2lf\n", students[i].name, students[i].age, students[i].score);
                }
                else
                {
                    printf("%s %d %.2lf", students[i].name, students[i].age, students[i].score);
                }
            */
        }
    }
    return 0;
}